package algorithm.poj.p3000;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLDecoder;


/**
 * 分析：
 * 
 * 实现：
 * 
 * 经验和教训：
 * 
 * 
 * @author wong.tong@gmail.com
 *
 */
public class P3094 {

	public static void main(String[] args) throws Exception {

		InputStream input = null;
		if (false) {
			input = System.in;
		} else {
			URL url = P3094.class.getResource("P3094.txt");
			File file = new File(URLDecoder.decode(url.getPath(), "UTF-8"));
			input = new FileInputStream(file);
		}
		
		BufferedReader stdin = new BufferedReader(new InputStreamReader(input));

		String line = stdin.readLine();
		while (line != null && !"#".equals(line.trim())) {
			System.out.println(quicksum(line.trim()));
			line = stdin.readLine();
		}
	}

	private static long quicksum(String line) {
		
		long sum = 0;
		char[] cs = line.toCharArray();
		for (int i = 0; i < cs.length; i ++) {
			if (cs[i] != ' ') {
				sum += (i+1)*((cs[i]-'A')+1);
			}
		}
		return sum;
	}
}